<?php

require_once "jssdk.php";

$数据=pdo()->selectColumns('public_serv_accounts',array('AppSecret','app_id'),array('id'=>$_SESSION['vo用户数据']['公众号ID']));

$jssdk = new JSSDK($数据['app_id'], $数据['AppSecret']);
$signPackage = $jssdk->getSignPackage();

global $openId;
$openId=getCurrentUserOID();//id
$bm=new CUI数据中心(Page::m卖家中心_账目,$openId);
$注册 = $bm->生成有效链接('register',$_GET['state']);
$店铺id = $_SESSION['vo用户数据']['所属店铺id'];
$用户id = $_SESSION['vo用户数据']['id'];
//$用户id=$bm->vc当前用户->vo用户数据->get_id();

$区域 = pdo()->selectAll('SELECT * FROM 区域');
$sql = "SELECT a.头像 as 头像,a.密码 as 密码 ,a.认证 as 认证 ,b.*,c.区域 as 区域 from 用户 as a left join 医师详情 as b  on a.id = b.用户id left join 区域 as c on b.区域id = c.id  where a.id = $用户id";
$个人信息 = pdo()->selectOne($sql);

$上传工作证 = $bm->生成有效链接('Seller18RenZheng',$_GET['state']);
$推广详情 = $bm->生成有效链接('Seller11Qrcodelist',$_GET['state']);
if($个人信息['密码']==""){
    header("Location:".$注册);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no"/>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title><?php if($个人信息['name']){echo '爱贝儿医';}else{echo '资料完善';}?></title>
    <link rel="stylesheet" href="../style/common.css">
    <script src="../resource/js/jquery-1.11.1.min.js"></script>
    <script src="//res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script src="http://demo.open.weixin.qq.com/jssdk/js/api-6.1.js?ts=1420774989"></script>
    <script src="../../app/js/common.js"></script>
    <script type="text/javascript">
            var images = {
                localId: [],
                serverId: []
            };

            wx.config({
                debug: false,
                appId: '<?php echo $signPackage["appId"];?>',
                timestamp: <?php echo $signPackage["timestamp"];?>,
                nonceStr: '<?php echo $signPackage["nonceStr"];?>',
                signature: '<?php echo $signPackage["signature"];?>',
                jsApiList: [
                    'startRecord',
                    'stopRecord',
                    'onRecordEnd',
                    'playVoice',
                    'pauseVoice',
                    'stopVoice',
                    'uploadVoice',
                    'downloadVoice',
                    'chooseImage',
                    'previewImage',
                    'uploadImage',
                    'downloadImage',
                    'onMenuShareAppMessage',
                    'onMenuShareTimeline',
                    'onMenuShareQQ',
                    'onMenuShareWeibo',
                    'onMenuShareQZone'
                ]
            });

            title = '爱贝儿医';
            desc = '爱贝儿医—专注于做儿科医生间学习工作交流平台。平台拥有数十位来自省级以上重点三甲医院的儿科专家、重点医院儿科学科带头人、国内儿科权威人士组成的豪华专家团队。';
            links = '';
            imgUrl = '<?= G_SITE_BASE ?>/business/img/logoRed2.png';
            weixinShare(title, desc, links, imgUrl);

            function uploadimg(){

                wx.chooseImage({
                    count: 1, // 默认9
                    sizeType: ['compressed'], // 可以指定是原图还是压缩图，默认二者都有
                    sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
                    success: function (res) {
                        localIds = res.localIds; // 返回选定照片的本地ID列表，localId可以作为img标签的src属性显示图片
                        syncUpload(localIds);
                    }
                });
            }

            var syncUpload = function(localIds){
                var localId = localIds.pop();
                wx.uploadImage({
                    localId: localId,
                    isShowProgressTips: 1,
                    success: function (res) {

                        var imageId = res.serverId; // 返回图片的服务器端ID
                        var userid = $('#用户id').val(); //get user id

                        $.post('agent_manages.php',{'imageId':imageId,"userid":userid,'参数':'上传个人真实照片'},function(data){
                        $("#preview").attr("src",data);
                        })

                    }
                });
            };
               

        </script>
</head>

<body>


<!--头部固定-->
<div class="header">
        <div class="header"><a href="#" class="return">返回</a></div>
</div>
<div class="renzheng-cont">
    <div class="renzheng-img" onclick="uploadimg()">
        <div id="localImag"  class="img"><img id="preview" src="<?php if(empty($个人信息['头像'])){echo 'style/renxiang.png' ;} else{ echo $个人信息['头像']; }  ?>"  style="display: block;"></div>
        <p class="word">请上传个人真实照片头像</p>
    </div>

<form class="form-horizontal" name="form1" id="form1"  action="../commit.php" method="post" enctype="multipart/form-data">
    <input type="hidden" name="businessFlag" value="资料完善<?php if ($个人信息['id']){echo '修改';}?>">
    <input type="hidden" name="医师详情id" value="<?=$个人信息['id']?>">
    <input type="hidden" name="上传工作证" value="<?=$上传工作证?>">
    <input type="hidden" id="用户id" name="用户id" value="<?=$用户id?>">
    <div class="AMu-form">
            <div class="AMu-form-list">
                <div class="AMu-form-list-title"><div>姓名</div></div>
                <div class="AMu-form-list-cont"><input type='text' class="input" name="name" id="name" value="<?=$个人信息['name']?>"  onFocus="this.style.color='#000'" onBlur="this.style.color='#ccc'"></div>
                <div class="clear"></div>
            </div>

            <div class="AMu-form-list">
                <div class="AMu-form-list-title"><div>所在医院</div></div>
                <div class="AMu-form-list-cont"><input type='text' class="input" id="yiyuan" name="医院" value="<?=$个人信息['医院']?>"  onFocus="this.style.color='#000'" onBlur="this.style.color='#ccc'" /></div>
                <div class="clear"></div>
            </div>
            <div class="AMu-form-list">
                <div class="AMu-form-list-title"><div>职务</div></div>
                <div class="AMu-form-list-cont"><input type='text' class="input" id="zhiwu" name="职务"   value="<?=$个人信息['职务']?>" onBlur="this.style.color='#ccc'" onFocus="this.style.color='#000'"/></div>
                <div class="clear"></div>
            </div>
            <div class="AMu-form-list">
                <div class="AMu-form-list-title"><div>专业领域</div></div>
                <div class="AMu-form-list-cont"><input type='text' class="input" name="专业领域"  value="<?=$个人信息['专业领域']?>"   onBlur="this.style.color='#ccc'" onFocus="this.style.color='#000'"/></div>
                <div class="clear"></div>
            </div>
    </div>
    <div class="geren-cont">
        <textarea name="简介" id="" placeholder="填写个人简历 获得更多关注"  style="text-align:left;"  onBlur="this.style.color='#ccc'"><?=$个人信息['简介']?></textarea>
    </div>
    <div class="next"><input type="submit" id="submit"  value="下一步"/></div>
</div>
        
</form>
<div style="width:100%;height:30px;"></div>
<div style="height:30px;width:100%;background:#db3655;color:#fff;font-size:80%;line-height:30px;text-align:center;position:fixed;bottom:0px;">操作过程中如有疑问，请致电客服热线：400-825-8989</div></body>
</body>
</html>
<script type="text/javascript">
    $(function(){
        $("#submit").click(function(){
            var name=$.trim($("input[name='name']").val());
            var yiyuan=$.trim($("#yiyuan").val());
            var zhiwu=$.trim($("#zhiwu").val());
            if((name.length)+(yiyuan.length)+(zhiwu.length)==0){
                alert("请完善您的个人资料!");
                return false;
            }
            if(name.length==0){
                alert("请输入您的姓名!");
                return false;
            }
            if(yiyuan.length==0){
                alert("请输入您的所在医院!");
                return false;
            }
            if(zhiwu.length==0){
                alert("请输入您的职务!");
                return false;
            }
            $("#form1").submit();
        });
    });
</script>
